$(function(){
    loginName=baseFunction.getUrlParameterValueByKey("loginName");
    saleLevel=baseFunction.getUrlParameterValueByKey("saleLevel"); //用户等级
    maxQuota="";  //最大额度
    init();
    
    // 提现
    $("#withdraw").on("click",function(){
        withdraw();
    })
})
/**
 * 页面初始化
 */
function init(){
    var data = {
        userName: baseFunction.encryption(loginName),
        queryType: "4631",
    }
    baseFunction.netRequest("param", data, function (res) {
        var pageInfo=JSON.parse(JSON.parse(res.data).result);
        maxQuota=pageInfo.availCash;
        $(".head .balance").html((pageInfo.availCash).toFixed(2));// 可提现金额
        $(".Details .yesterdayEarnings").html((pageInfo.yesterday).toFixed(2));// 昨天收益
        $(".Details .todayIncome").html((pageInfo.today).toFixed(2));// 今天收益
        $(".Details .cumulativeIncome").html((pageInfo.total).toFixed(2));// 累计收益
    })
    // 历史记录
    $("#historyRecord").on("click",function(){
        window.location.href="wallet_historyRecord.html?current=2&loginName="+loginName+"";
    })
}

/**
 * 提现
 */
function  withdraw() {
    //判断是否实名制
    baseFunction.verifyingRealName();
    //判断等级
    if (saleLevel != 3) {
        $(".mask .tip").html("黄金会员才能使用提现功能，请先升级用户等级");
        $(".mask").show(0);
        var btn=document.querySelector(".mask .btn");
        var mask=document.querySelector(".mask");
        btn.onclick=function(){
            window.location.href="index_shareUpgrade.html?loginName="+ loginName + "&saleLevel=" + saleLevel + ""
        }
    } else {//3 是黄金
        window.location.href="wallet_withdraw.html?current=2&loginName=" + loginName + "&maxQuota=" + maxQuota+"";
    }
}